<?php

namespace Home\Model;
use Think\Model;

class DataFileModel extends Model {
	//录入
	public function insertOne($data){
		if(empty($data)) return false;

		$result = $this->data($data)->add();
		// echo $this->getlastsql();
		return $result;
	}

	public function getInfoWithId($id){
		if(empty($id) || !is_numeric($id)) return null;
		return $this->where('id='.$id)->find();
	}

	//获取文件列表
	public function getList($uid,$page = 1, $pagesize = 20){
		if(empty($uid) || !is_numeric($uid)) return null;

		$where['uid'] = $uid;
		$where['status'] = array('egt',0);
		$count = $this->where($where)->count();
		$list = $this->where($where)->limit( ($page-1)*$pagesize,$pagesize)->select();

		$data['count'] = $count;
		$data['list'] = $list;
		return $data;
	}

	//删除
	public function deleteOne($id){
		if(empty($id)) return false;

		$where['id'] = $id;
		$data['status'] = -1;//删除（逻辑删除）
		return $this->where($where)->save($data);

	}

}
?>